package cn.yyt.yytravel.community.controller;

import cn.yyt.yytravel.base.response.JsonResult;
import cn.yyt.yytravel.community.pojo.dto.CommentQuery;
import cn.yyt.yytravel.community.pojo.dto.CommentSaveParam;
import cn.yyt.yytravel.community.pojo.entity.Comment;
import cn.yyt.yytravel.community.pojo.vo.CommentVO;
import cn.yyt.yytravel.community.service.CommentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/yyt/comment/")
public class CommentController {

    @Autowired
    CommentService commentService;

    @PostMapping("saveComment")
    public JsonResult saveComment(CommentSaveParam commentSaveParam){
        commentService.saveComment(commentSaveParam);
        return JsonResult.ok();
    }

    @GetMapping("selectComment")
    public JsonResult selectComment(CommentQuery commentQuery){
        List<CommentVO> list = commentService.selectComment(commentQuery);
        return JsonResult.ok(list);
    }
}
